from .config_data.case_data import *
import pytest
from tool_class.page_handle import LabelManagePageHandle


@pytest.fixture(scope='module')
def project_management_module(session_page):
    handle = LabelManagePageHandle(session_page)
    #进入项目标签管理页面
    handle.goto_local(url_path="/ins/#/project/projectList")
    yield session_page, handle


@pytest.mark.parametrize("unit",[project_query_01,project_query_02,project_query_03])
@pytest.mark.run(order=700)
def test_project_management_query_01(unit,project_management_module):
    """ 查询标签应用列表 """
    session_page,handle = project_management_module
    result = handle.query_handle(unit)
    keys = list(result.keys())
    first_key = keys[0]
    last_key = keys[-1]
    no_data = session_page.locator('.arco-empty-description').first
    if no_data.is_visible():
        assert no_data.inner_text() == result[last_key] \
               and not session_page.get_by_role("alert").is_visible()
    else:
        assert all(result[first_key] in itme for itme in result[last_key]) \
               and not session_page.get_by_role("alert").is_visible()
    handle.element_click("projectList-1004")  # 重置查询